import java.util.List;
import java.util.ArrayList;

public class Problem48 {
	public static void main(String[] args) {
		List<Integer> sum = new ArrayList<Integer>();
		sum.add(0);

		for (int i = 1; i <= 1000; i++) {
			List<Integer> base = new ArrayList<Integer>();
			int n = i;
			while(n > 0) {
				base.add(n%10); 
				n /= 10;
			}

			List<Integer> term = power(base, i);
			sum = add(sum, term);
		}
		
		StringBuffer sb = new StringBuffer();
		for (int i : sum)
			sb.append(i);
		
		System.out.println(sb.reverse().toString());
	}

	private static List<Integer> add(List<Integer> a, List<Integer> b) {
		if (a.size() == 0 || a.size() == 1 && a.get(0) == 0)
			return b;

		if (b.size() == 0 || b.size() == 1 && b.get(0) == 0)
			return a;
		
		List<Integer> result = new ArrayList<Integer>();
		int len = Math.max(a.size(), b.size());
		int carry = 0;

		for (int i = 0; i < len; ++i) {
			int sum = carry;
			if (i < a.size())
				sum += a.get(i);
			if (i < b.size())
				sum += b.get(i);

			result.add(sum%10);
			carry = sum/10;
		}

		if (carry > 0)
			result.add(carry);

		return result;
	}

	private static List<Integer> power(List<Integer> x, int n) {
		assert (n >= 0);

		if (n == 1) {
			return x;
		}

		List<Integer> result = new ArrayList<Integer>();
		result.add(1);
		
		if (n == 0) {
			return result;
		}

		List<Integer> temp = new ArrayList<Integer>(x);
	
		while (n > 0) {
			if ((n & 1) == 1)
				result = multiply(result, temp);
			temp = multiply(temp, temp);
			n >>= 1;
		}

		return result;
	}

	private static List<Integer> multiply(List<Integer> a, List<Integer> b) {
		List<Integer> result = new ArrayList<Integer>();
		if (a.size() == 0 || b.size() == 0) {
			result.add(0);
			return result;
		}

		if (a.size() == 1 && a.get(0) == 1)
			return b;
		if (b.size() == 1 && b.get(0) == 1)
			return a;

		int len = a.size() + b.size();
		int carry = 0;

		for (int i = 0; i < len-1; ++i) {
			int sum = carry;
			for (int j = 0; j < a.size() && j <= i; j ++) {
				if (i - j < b.size())
					sum += a.get(j)*b.get(i-j);
			}

			result.add(sum%10);
			carry = sum/10;
		}

		if (carry > 0)
			result.add(carry);

		return result;
	}
}
